package com.gxa.p2p.controller;


import com.gxa.p2p.service.InvestRecordService;
import com.gxa.p2p.util.ReturnMap;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 *投标信息模块
 */
@Api(value = "投标明细控制器",tags = "投标明细操作接口")
@CrossOrigin
@Controller
@RequestMapping("/InvestRecord")
public class InvestRecordController {

    @Resource(name = "investRecordServiceImpl")
    InvestRecordService investRecordService;

    @ApiOperation(value = "查询投标收款明细接口",notes = "查询以投标的收款信息",
    response = Map.class,httpMethod = "GET")
    @ApiImplicitParams({@ApiImplicitParam(name = "userId",dataType = "int",required = true),
            @ApiImplicitParam(name = "page",dataType = "int",required = true),
            @ApiImplicitParam(name = "limit",dataType = "int",required = true)})
    @GetMapping("/getInvest")
    @ResponseBody
    public Map<String, Object> findInvest(@RequestParam("userId") Integer userId,Integer page,Integer limit){
        List<Object> invest = investRecordService.findInvest(userId, page, limit);
        ReturnMap<Object> objectReturnMap = new ReturnMap<>();
        return objectReturnMap.returnMap(invest);
    }
    @ApiOperation(value = "类型模糊查询投标收款明细接口",notes = "类型模糊查询以投标的收款信息",
            response = Map.class,httpMethod = "GET")
    @ApiImplicitParams({@ApiImplicitParam(name = "userId",dataType = "int",required = true),
            @ApiImplicitParam(name = "page",dataType = "int",required = true),
            @ApiImplicitParam(name = "limit",dataType = "int",required = true)})
    @GetMapping("/getInvestDim")
    @ResponseBody
    public Map<String, Object> findInvestDim(@RequestParam("userId") Integer userId,
                                             @RequestParam("incomeMode") String Str,
                                             @RequestParam("page") Integer page,
                                             @RequestParam("limit") Integer limit){
        List<Object> invest = investRecordService.findInvestDim(userId,Str, page, limit);
        ReturnMap<Object> objectReturnMap = new ReturnMap<>();
        return objectReturnMap.returnMap(invest);
    }

    @ApiOperation(value = "查询用户所投标信息",tags = "查询用户所投标信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "userId",dataType = "int",required = true),
            @ApiImplicitParam(name = "page",dataType = "int",required = true),
            @ApiImplicitParam(name = "limit",dataType = "int",required = true)})
    @GetMapping("/findUserRce")
    @ResponseBody
    public Map<String, Object> findUserRce(@RequestParam("userId") Integer userId,Integer page, Integer limit){
        ArrayList<Object> userRec = investRecordService.findUserRec(userId, page, limit);
        ReturnMap<Object> objectReturnMap = new ReturnMap<>();
        return objectReturnMap.returnMap(userRec);
    }

    @ApiOperation(value = "根据标名模糊查询用户所投标信息",tags = "根据标名模糊查询用户所投标信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "userId",dataType = "int",required = true),
            @ApiImplicitParam(name = "bidName",dataType = "string",required = true),
            @ApiImplicitParam(name = "page",dataType = "int",required = true),
            @ApiImplicitParam(name = "limit",dataType = "int",required = true),
    })
    @GetMapping("/findUserRceDim")
    @ResponseBody
    public Map<String, Object> findUserRceDim(@RequestParam("userId") Integer userId,
                                              @RequestParam("bidName") String bidName,
                                              @RequestParam("page") Integer page,
                                              @RequestParam("limit") Integer limit){
        ArrayList<Object> userRec = investRecordService.findUserRecDim(userId, bidName,page, limit);
        ReturnMap<Object> objectReturnMap = new ReturnMap<>();
        return objectReturnMap.returnMap(userRec);
    }
}
